//
//  UIButton+Extension.swift
//  SinaWeibo
//
//  Created by QUAN on 15/11/13.
//  Copyright © 2015年 QUAN. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(title: String?, image: String?, backImage: String?, color: UIColor?, size: CGFloat = 14) {
        
        self.init()
        
        if title != nil {
            setTitle(title!, forState: .Normal)
        }
        
        if image != nil {
            setImage(UIImage(named: image!), forState: .Normal)
            setImage(UIImage(named: image! + "_highlighted"), forState: .Selected)
        }
        if backImage != nil {
            
            setBackgroundImage(UIImage(named: backImage!), forState: .Normal)
            setBackgroundImage(UIImage(named: backImage! + "_highlighted"), forState: .Highlighted)
        }
        
        titleLabel?.font = UIFont.systemFontOfSize(size)
        
        if color != nil {
            setTitleColor(color!, forState: .Normal)
        }
        
    }
    
}



